//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef __ELASTOS_INTERRUPT_H__
#define __ELASTOS_INTERRUPT_H__

typedef struct InterruptContext
{
    /* Pad bytes for argument save space on the stack. */
    unsigned long pad0[6];

    /* Saved main processor registers. */
    unsigned long regs[32];

    /* Other saved registers. */
    unsigned long lo;
    unsigned long hi;

    /*
     * saved cp0 registers
     */
    unsigned long cp0_epc;
    unsigned long cp0_badvaddr;
    unsigned long cp0_status;
    unsigned long cp0_cause;
} InterruptContext, CXTINFO, *PCXTINFO;

typedef enum
{  
    ZERO,
    ATF,
    V0,V1,
    A0,A1,A2,A3,
    T0,T1,T2,T3,T4,T5,T6,T7,
    S0,S1,S2,S3,S4,S5,S6,S7,
    T8,T9,
    K0,K1,
    GP,SP,
    FP,
    RA
} regnames;

EXTERN_C void DumpCxt(InterruptContext *pContext);
EXTERN_C void DumpEPC(InterruptContext *pCxt);

typedef void (CDECL *isr_t)(irq_t, void *, InterruptContext *);

EXTERN void CDECL DzRegisterIsr(irq_t irq, ipl_t ipl, isr_t isr, void *pvDevice);
EXTERN void CDECL DzUnregisterIsr(irq_t irq);

EXTERN void CDECL DzEnableIrq(irq_t irq);
EXTERN void CDECL DzDisableIrq(irq_t irq);

EXTERN ipl_t CDECL DzRaiseCurrentIpl(ipl_t ipl);
EXTERN ipl_t CDECL DzLowerCurrentIpl(ipl_t ipl);

#endif // __ELASTOS_INTERRUPT_H__
